package com.resou.reader.bookstore.category.adapter;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.internal.FlowLayout;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.resou.reader.R;
import com.resou.reader.api.entry.BookCategoryBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ${Garrett} on 2018/9/29.
 * Contact me krouky@outlook.com
 */
public class SubCategoryAdapter extends BaseQuickAdapter<BookCategoryBean, BaseViewHolder> {


    public SubCategoryAdapter(int layoutResId, @Nullable List<BookCategoryBean> data) {
        super(layoutResId, data);
    }

    public SubCategoryAdapter(@Nullable List<BookCategoryBean> data) {
        super(data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BookCategoryBean item) {
        try {
            helper.addOnClickListener(R.id.llContentOnclick);
            Glide.with(mContext).load(item.getCoverUrl() == null ? "" : item.getCoverUrl()).into((ImageView) helper.getView(R.id.tvBookPic));
            helper.setText(R.id.tvBookName, item.getNovelName() + "");
            helper.setText(R.id.tvDes, item.getContent() + "");
            helper.setText(R.id.tvAuthor, item.getAuthorName() + "");
            helper.setText(R.id.tvLabel, item.getParentCategoryName() + "");
        } catch (Exception e) {
            Log.i(TAG, "convert: " + e.getMessage());
        }
    }
}
